home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / mig / dist / mig.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1992-04-09  |  4.5 KB  |  157 lines

  1. #!/bin/sh
  2. #
  3. # Mach Operating System
  4. # Copyright (c) 1991,1990 Carnegie Mellon University
  5. # All Rights Reserved.
  6. # Permission to use, copy, modify and distribute this software and its
  7. # documentation is hereby granted, provided that both the copyright
  8. # notice and this permission notice appear in all copies of the
  9. # software, derivative works or modified versions, and any portions
  10. # thereof, and that both notices appear in supporting documentation.
  11. # CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  12. # CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  13. # ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  14. # Carnegie Mellon requests users of this software to return to
  15. #  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  16. #  School of Computer Science
  17. #  Carnegie Mellon University
  18. #  Pittsburgh PA 15213-3890
  19. # any improvements or extensions that they make and grant Carnegie Mellon
  20. # the rights to redistribute these changes.
  21. #
  22. #
  23. # HISTORY
  24. # $Log:    mig.sh,v $
  25. # Revision 2.9  92/04/01  19:36:14  rpd
  26. #     Added option -cc arg
  27. #     It informs mig that it should use the C compiler driver to
  28. #     call the preprocessor. The argument gives the name of the 
  29. #     driver and the flags that make it preprocess.
  30. #     [92/03/18            jvh]
  31. # Revision 2.8  92/01/23  15:21:28  rpd
  32. #     Changed to generate a dependency on migcom itself.
  33. #     [92/01/19            rpd]
  34. # Revision 2.7  92/01/14  16:46:20  rpd
  35. #     Removed -theader switched.
  36. #     Fixed dependency file generation to remove /dev/null.
  37. #     [92/01/10            rpd]
  38. # Revision 2.6  91/07/31  18:09:45  dbg
  39. #     Allow both -header and -sheader switches.
  40. #     Fix copyright.
  41. #     [91/07/30  17:14:28  dbg]
  42. # Revision 2.5  91/06/25  10:31:42  rpd
  43. #     Added -sheader.
  44. #     [91/05/23            rpd]
  45. # Revision 2.4  91/02/05  17:55:08  mrt
  46. #     Changed to new Mach copyright
  47. #     [91/02/01  17:54:47  mrt]
  48. # Revision 2.3  90/06/19  23:01:10  rpd
  49. #     The -i option takes an argument now.
  50. #     [90/06/03            rpd]
  51. # Revision 2.2  90/06/02  15:05:05  rpd
  52. #     For BobLand: changed /usr/cs/bin/wh to wh.
  53. #     [90/06/02            rpd]
  54. #     Created for new IPC.
  55. #     [90/03/26  21:12:04  rpd]
  56. # 27-May-87  Richard Draves (rpd) at Carnegie-Mellon University
  57. #    Created.
  58. #
  59.  
  60. MIGCOM=`wh -Lq migcom`
  61.  
  62. usecc=false
  63. cppflags=
  64. migflags=
  65. files=
  66.  
  67. # If an argument to this shell script contains whitespace,
  68. # then we will screw up.  migcom will see it as multiple arguments.
  69. #
  70. # As a special hack, if -i is specified first we don't pass -user to migcom.
  71. # We do use the -user argument for the dependencies.
  72. # In this case, the -user argument can have whitespace.
  73.  
  74. until [ $# -eq 0 ]
  75. do
  76.     case "$1" in
  77.     -[qQvVtTrRsS] ) migflags="$migflags $1"; shift;;
  78.     -i    ) sawI=1; migflags="$migflags $1 $2"; shift; shift;;
  79.     -user   ) user="$2"; if [ ! "${sawI-}" ]; then migflags="$migflags $1 $2"; fi; shift; shift;;
  80.     -server ) server="$2"; migflags="$migflags $1 $2"; shift; shift;;
  81.     -header ) header="$2"; migflags="$migflags $1 $2"; shift; shift;;
  82.     -sheader ) sheader="$2"; migflags="$migflags $1 $2"; shift; shift;;
  83.     -iheader ) iheader="$2"; migflags="$migflags $1 $2"; shift; shift;;
  84.  
  85.     -MD ) sawMD=1; cppflags="$cppflags $1"; shift;;
  86.     -cc) usecc=true; CPP="$2"; shift; shift;;
  87.     -* ) cppflags="$cppflags $1"; shift;;
  88.     * ) files="$files $1"; shift;;
  89.     esac
  90. done
  91.  
  92. CPP="${CPP-`wh -Lq cpp`}"
  93.  
  94. for file in $files
  95. do
  96.     base="`/usr/bin/basename "$file" .defs`"
  97.     if $usecc; then
  98.         $CPP $cppflags "$file" | $MIGCOM $migflags || exit
  99.     else
  100.             $CPP $cppflags "$file" - ${sawMD+"$base".defs.d~} |
  101.                     $MIGCOM $migflags || exit
  102.     fi
  103.     if [ $sawMD ]
  104.     then
  105.     deps=
  106.     s=
  107.     rheader="${header-${base}.h}"
  108.     if [ "$rheader" != /dev/null ]; then
  109.         deps="${deps}${s}${rheader}"; s=" "
  110.     fi
  111.     ruser="${user-${base}User.c}"
  112.     if [ "$ruser" != /dev/null ]; then
  113.         deps="${deps}${s}${ruser}"; s=" "
  114.     fi
  115.     rserver="${server-${base}Server.c}"
  116.     if [ "$rserver" != /dev/null ]; then
  117.         deps="${deps}${s}${rserver}"; s=" "
  118.     fi
  119.     rsheader="${sheader-/dev/null}"
  120.     if [ "$rsheader" != /dev/null ]; then
  121.         deps="${deps}${s}${rsheader}"; s=" "
  122.     fi
  123.     riheader="${iheader-/dev/null}"
  124.     if [ "$riheader" != /dev/null ]; then
  125.         deps="${deps}${s}${riheader}"; s=" "
  126.     fi
  127. # fixup dependencies, adding a dependency on migcom itself
  128.     if $usecc; then
  129.         { sed 's;^'"$base"'.o;'"$deps"';' < "$base".d; \
  130.         echo "${deps}: ${MIGCOM}"; } > "$base".defs.d
  131.                rm -f "$base".d
  132.  
  133.     else
  134.         { sed 's;^'"$base"'.o;'"$deps"';' < "$base".defs.d~; \
  135.           echo "${deps}: ${MIGCOM}"; } > "$base".defs.d
  136.         rm -f "$base".defs.d~
  137.     fi
  138.  
  139.     fi
  140. done
  141.  
  142. exit 0
  143.